<?php
Yii::import('Cms.components.widgets.BaseCmsWidget');
class CmsGoogleAnalytic extends BaseCmsWidget {
    
    public function run(){
        $models = $this->getActiveDataProvider()->getData();
        if (count($models))
        {
            $model = $models[0];
            Yii::app()->clientScript->registerScript($model->code, CClientScript::POS_END);
        }
        return '';
    }
    
    // this widget does not have layout
    public function getSelectedLayout() {
        return null;
    }
    
    // return the url to edit text content
    public function getEditUrl($params = array()){
        $params['workflow_id'] = Yii::app()->cmsManager->workflow['id'];
        $params['id'] = $this->dataSettings['params'][':id'];
        
        return url('/Cms/widgets/cmsGoogleAnalytic/update', $params);
    }
    
    public function getSettingParams()
    {
        return array(
            'ShowAllPage' => array(  
                'type' => 'checkbox',
                'htmlOptions' => array('value' => 1)
            ),
        );
    }
}
